package com.pmcc.platform.user.repository;

import com.pmcc.platform.user.entity.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Date;
import java.util.List;

public interface MessageRepository extends JpaRepository<Message, String> {
    List<Message> findByTelephoneAndMessageType(String telPhone, String type);

    List<Message> findByTelephoneAndMessageContent(String telPhone, String messageContent);

    Page<Message> findAll(Specification<Message> specification, Pageable pageable);

    List<Message> findByTelephoneAndMessageTypeAndStatus(String telephone, String messageType, String status);

    List<Message> findByTelephoneAndMessageContentAndMessageTypeAndStatus(String telephone, String messageContent, String messageType, String status);

    List<Message> findByTelephoneAndMessageContentAndMessageType(String telPhone, String messageContent, String messageType);

    List<Message> findByTelephoneAndMessageTypeAndStatusAndMessageSendTimeAfter(String telephone, String messageType, String status, Date data);

    List<Message> findTopByIpOrderByMessageSendTimeDesc(String ip);
}
